package de.bazinga.rotw.game;

import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.Text;

public class TextField extends Node {
	private static final long serialVersionUID = 1L;
	
	protected Text textObject = null;
	
	private String text = "";
	private Vector3f pos = null;
	
	public TextField(String text, ColorRGBA textColor, Vector3f position, float scale) {
		super("TextNode");
		
		this.text = "";
		this.pos = position;
		
		textObject = Text.createDefaultTextLabel("Text", text);
		textObject.setTextureCombineMode(TextureCombineMode.Replace);
		textObject.setTextColor(textColor);
		
		this.attachChild(textObject);
		this.setLocalTranslation(position);
		this.setLocalScale(scale);
		this.updateGeometricState(0.0f, true);
		this.updateRenderState(); 
	}
	
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
		
		textObject.print(text);
	}

	public Vector3f getPos() {
		return pos;
	}

	public void setPos(Vector3f pos) {
		this.pos = pos;
	}

	public Text getTextObject() {
		return textObject;
	}
}
